
//路由配置配置文件
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

//引入组件
import {HomeComponent} from "./components/home/home.component";
import {NewsComponent} from "./components/news/news.component";
import {UserComponent} from "./components/user/user.component";
import {NewscontentComponent} from "./components/newscontent/newscontent.component";
import {ShoplistComponent} from "./components/shoplist/shoplist.component";
import {ShopcateComponent} from "./components/shopcate/shopcate.component";
import {WelcomeComponent} from "./components/welcome/welcome.component";

const routes: Routes = [//定义路由和组件的关系
  {
     path:'home',
     component:HomeComponent,
     children:[//子路由
       {
         path:'welcome',
         component:WelcomeComponent
       }
     ]
  },
  {
    path:'shoplist',
    component:ShoplistComponent,
    children:[//子路由
      {
        path:'shopcate',
        component:ShopcateComponent
      },
    ]
  },
  {
    path:'newscontent/:aid', //动态路由
    component:NewscontentComponent
  },
  {
    path:'news',
    component:NewsComponent
  },
  {
    path:'user',
    component:UserComponent
  },
  {
    path:'', //配置默认路由
    redirectTo:'home',
    pathMatch:'full'
  },
  {
    path:'**', //匹配不到路由
    component:HomeComponent
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }




